package top.cardone.security.shiro.func;

import org.apache.shiro.SecurityUtils;
import top.cardone.core.util.func.Func0;
import top.cardone.core.util.func.Func1;

import java.util.Map;

/**
 * Created by yht on 16-3-28.
 */
public class ReadPrincipalFunc implements Func0<String>, Func1<String, Map<String, Object>> {
    @Override
    public String func() {
        Object principal = SecurityUtils.getSubject().getPrincipal();

        if (principal == null) {
            return null;
        }

        return principal.toString();
    }

    @Override
    public String func(Map<String, Object> stringObjectMap) {
        return this.func();
    }
}
